#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/12/27 14:46
# @Author: 张磊
# @Email: 1273104996@qq.com
# @File：attention_page.py
from appium.webdriver.common.mobileby import MobileBy as By
from pages.base_page import BasePage

class Attention(BasePage):
    # 紫薯布丁定位器
    works_locator = (
    By.XPATH, "//android.widget.TextView[@resource-id=\"com.gfeng.daydaycook:id/title\" and @text=\"紫薯布丁\"]")
    # 点赞定位器
    like_locator = (By.ID, "com.gfeng.daydaycook:id/like_imageview")
    # 评论定位器
    comment_locator = (By.XPATH, "//android.widget.TextView[@resource-id=\"com.gfeng.daydaycook:id/tv_comment\"]")
    # 评论框输入定位器
    comment_input_locator = (By.ID, "com.gfeng.daydaycook:id/et_comment")
    # 发送定位器
    send_locator = (By.ID, "com.gfeng.daydaycook:id/tv_commit")
    # 收藏定位器
    collect_locator = (By.ID, "com.gfeng.daydaycook:id/iv_collection")
    # 搜索框定位器
    search_box_locator = (By.ID, "com.gfeng.daydaycook:id/searchIv")
    # 热门搜索蛋糕定位器
    hot_cake_locator = (By.XPATH, "//android.widget.TextView[@text=\"蛋糕\"]")

    def click_works(self):  # 点击作品
        self.driver.find_element(*self.works_locator).click()

    def click_like(self):   # 点击点赞
        self.driver.find_element(*self.like_locator).click()

    def click_comment(self):  # 点击评论
        self.driver.find_element(*self.comment_locator).click()

    def click_comment_input(self,evaluate):  # 点击评论输入框定位器
        self.driver.find_element(*self.comment_input_locator).send_keys(evaluate)

    def click_send(self):   # 点击发送
        self.driver.find_element(*self.send_locator).click()

    def click_clooect(self):  # 点击收藏
        self.driver.find_element(*self.collect_locator).click()

    def click_search(self):   # 点击搜索
        self.driver.find_element(*self.search_box_locator).click()

    def get_attention_activity(self):  # 获取点赞页面的activity
        return  self.driver.current_activity

    def click_hot_cake(self): # 点击热门搜索的蛋糕
        self.driver.find_element(*self.hot_cake_locator).click()




